package com.example.demo;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.awt.*;
import java.util.List;

@RestController
@RequestMapping("test")
public class HelloController {
    @RequestMapping("/print")
    public String print() {
        return "hello print";
    }

    @RequestMapping("p1")
    public String p1(String name) {

        return "name=" + name;
    }

    @RequestMapping("p2")
    public String p2(String name, Integer age) {

        return "name=" + name + ",age=" + age;
    }

    @RequestMapping("p3")
    public String p3(Person person) {
        return "person=" + person;
    }

    @RequestMapping("p4")
    public String p4(@RequestParam(value = "userName", required = false) String name) {
        return "name=" + name;
    }

    @RequestMapping("p5")
    public String p3(String[] arr) {
        return "arr" + List.of(arr);
    }

    @RequestMapping("p6/{artid}/{name}")
    public String p6(@PathVariable("artid") String artid, @PathVariable String name) {
        return "artid=" + artid + ",name=" + name;
    }

    @RequestMapping("p7")
    public String p7(@RequestPart("fileName") MultipartFile file) {
        System.out.println(file.getOriginalFilename());
        return "文件名称="+file.getOriginalFilename();
    }
}
